package hebClustering.vectorSpace.distances;

import hebClustering.vectorSpace.IVector;

/**
 * Implementation of the distance function Euclidian distance.
 * 
 *	@see <a href="http://en.wikipedia.org/wiki/Euclidean_distance" target="_blank">Euclidian distance</a>
 */
public class EuclidianDistance implements IDistance {

	@Override
	public double calc(IVector v1, IVector v2) {
		double sum = 0;
		IVector diff = v1.sub(v2);
		
		for(int i : diff){
			sum+=Math.pow(Math.abs(diff.ithValue(i)), 2);
		}
		
		return Math.pow(sum,(double) 1/2);
	}
}
